package com.作业.Day22;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * 用自己写的JDBC 实现数据库查询
 */
public class Homework1 {
    public static void main(String[] args) {
        //初始化。加载驱动
        MyJDBC myJDBC = new MyJDBC();
        //判断是否连接成功
//        Connection connect = myJDBC.isConnect();
//        插入数据
//        String sql = "insert into bookdb values(?,?,?,?,?,?)";
//        Object[] objects = {1,"java", 10.0, "123456", "java", "java"};
//        int update = myJDBC.updateDB(sql, objects);
//        System.out.println( update);
       //查询所有
//        String sql = "select * from bookdb";
//        myJDBC.queryDB(sql, new ResultSetHandler<Book>() {
//
//            @Override
//            public Book handle(ResultSet rs) throws SQLException {
//                Book book = new Book(rs.getInt(1),
//                        rs.getString(2), rs.getDouble(3),
//                        rs.getString(4), rs.getString(5),
//                        rs.getString(6));
//                return book;
//            }
//        });
//        /**
//         *删除
//         */
//        String sql = "delete from bookdb where id = ?";
//        int update = myJDBC.updateDB(sql, 1);
//        System.out.println(update);
    }
}
